package top.btcmarket.TestProject;

import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class TestJson {

	public static void main(String[] args) {
		
		String json = "{\"address\":\"0x0785d31CcfCB1f086D2b79a6F20821B06d4dB727\",\"transactions\":[{\"from\":\"0xF50De0831946F76B0eC7D3212008AF6fd419E902\",\"to\":\"0x0785d31CcfCB1f086D2b79a6F20821B06d4dB727\",\"value\":\"100000000\",\"hash\":\"0x93BEEAC140BE70280AF8ABDF65A83D636581A48E2DA623426E96777DDABE5304\",\"timestamp\":\"1523831973\"},{\"from\":\"0x0785d31CcfCB1f086D2b79a6F20821B06d4dB727\",\"to\":\"0xF50De0831946F76B0eC7D3212008AF6fd419E902\",\"value\":\"100000000\",\"hash\":\"0x660A27CBC35976DA159798234480B9389AF5DD14944EDE193CADF5FC39072B4A\",\"timestamp\":\"1522846882\"},{\"from\":\"0x7CF61D8394FDE5D2eFb0C39a34e57dc22dB93fb0\",\"to\":\"0x0785d31CcfCB1f086D2b79a6F20821B06d4dB727\",\"value\":\"100000000000000000\",\"hash\":\"0x1EA72B3FED3584957670036110D8EEA3CE01198501F97693D18C52A8E8CD8AA0\",\"timestamp\":\"1522455640\"}]}";
		
		JSONObject jj = JSONObject.parseObject(json);
		JSONArray jsonArray = jj.getJSONArray("transactions");
		for (int i = 0; i < jsonArray.size(); i++) {
			JSONObject arr = jsonArray.getJSONObject(i);
			
			System.out.println("-------------start------------------");
			System.out.println(arr.getString("from"));
			System.out.println(arr.getString("to"));
			System.out.println(arr.getString("value"));
			System.out.println(arr.getString("hash"));
			System.out.println(arr.getString("timestamp"));
			System.out.println("-------------end------------------");
		}
//		List<Map<String,Object>> data = (List<Map<String,Object>>)jsonArray.forEach(action);
		
		
		String jja = "{\"code\":\"0\",\"message\":null,\"validMsg\":{},\"data\":{\"id\":8490976332855826753,\"createTime\":\"2018-05-02 03:51:28.0\",\"updateTime\":\"2018-05-02 03:51:28.0\",\"openId\":null,\"securityId\":null,\"countryId\":1,\"inchatAccount\":\"icid_jf3mve5qk1n585r1c248\",\"phoneCode\":\"86\",\"phoneNumber\":\"13127966214\",\"email\":null,\"avatar\":\"https://chipsstatic.oss-cn-hangzhou.aliyuncs.com/live/core/images/y/logo.png\",\"langId\":null,\"vipLevel\":null,\"status\":1,\"token\":\"PLD+h55WVj8mo+LKmaFpG4+udIcsga12JOlM5GufWO6xp96BWYDHMGuXU3lzD1Ik1cS4lRSdcdI9KGJNsy9WHGb7BtjhcwdORm7A2zO+G+sSwsOwj24SOQ==\",\"signInfo\":null,\"sex\":null,\"nickname\":\"13127966214\",\"walletId\":null,\"rongyunResult\":null,\"salt\":null,\"area\":null,\"googleauthenticator\":null,\"personalphoto\":null},\"resultStatus\":true}";
		JSONObject jjaa = JSONObject.parseObject(jja);
		System.out.println(jjaa.getJSONObject("data"));
		JSONObject jsonObject = jjaa.getJSONObject("data");
		System.out.println(" id is : "+jsonObject.getLong("id"));
	}
}
